<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电子药方</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@2.12.47/lib/vant.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.12.47/lib/index.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        body {
            background-color: #f5f7fa;
            color: #333;
            padding: 16px;
            line-height: 1.6;
        }
        .prescription-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            overflow: hidden;
        }
        .prescription-header {
            background: linear-gradient(135deg, #1a8cff 0%, #0066cc 100%);
            color: white;
            padding: 20px;
            text-align: center;
        }
        .clinic-name {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 8px;
        }
        .prescription-title {
            font-size: 24px;
            font-weight: bold;
            margin: 10px 0;
        }
        .patient-info {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            padding: 16px 20px;
            background: #f0f7ff;
            border-bottom: 1px dashed #cce0ff;
        }
        .info-item {
            margin: 8px 0;
            flex: 1 0 50%;
        }
        .info-label {
            color: #666;
            font-size: 14px;
        }
        .info-value {
            font-weight: 500;
            margin-top: 4px;
        }
        .medication-section {
            padding: 20px;
        }
        .section-title {
            font-size: 18px;
            font-weight: bold;
            color: #0066cc;
            margin-bottom: 16px;
            padding-bottom: 8px;
            border-bottom: 2px solid #e6f2ff;
        }
        .medication-item {
            padding: 16px;
            margin-bottom: 16px;
            border-radius: 8px;
            background: #f9fbff;
            border-left: 4px solid #4d94ff;
        }
        .medication-name {
            font-size: 18px;
            font-weight: bold;
            color: #1a53ff;
            margin-bottom: 8px;
        }
        .medication-detail {
            display: flex;
            margin: 8px 0;
        }
        .detail-label {
            color: #666;
            min-width: 80px;
        }
        .dosage-instruction {
            background: #e6f2ff;
            padding: 12px;
            border-radius: 6px;
            margin-top: 12px;
        }
        .instruction-title {
            font-weight: bold;
            color: #0066cc;
            margin-bottom: 8px;
        }
        .instruction-item {
            display: flex;
            margin: 6px 0;
        }
        .instruction-time {
            min-width: 100px;
            font-weight: 500;
        }
        .caution-section {
            padding: 20px;
            background: #fff9e6;
            margin: 20px;
            border-radius: 8px;
            border-left: 4px solid #ffcc00;
        }
        .caution-title {
            font-weight: bold;
            color: #e68a00;
            margin-bottom: 12px;
        }
        .caution-list {
            padding-left: 20px;
        }
        .caution-list li {
            margin: 8px 0;
        }
        .doctor-info {
            padding: 20px;
            text-align: right;
            border-top: 1px dashed #ddd;
        }
        .doctor-name {
            font-weight: bold;
            margin: 8px 0;
        }
        .date-info {
            color: #666;
        }
        .action-buttons {
            display: flex;
            padding: 20px;
            gap: 12px;
        }
        .action-button {
            flex: 1;
            padding: 12px;
            border-radius: 8px;
            text-align: center;
            font-weight: 500;
            cursor: pointer;
        }
        .print-btn {
            background: #1a8cff;
            color: white;
        }
        .save-btn {
            background: #00cc66;
            color: white;
        }
        .footer {
            text-align: center;
            padding: 16px;
            color: #999;
            font-size: 14px;
        }
        @media (max-width: 600px) {
            .patient-info {
                flex-direction: column;
            }
            .info-item {
                flex: 1 0 100%;
            }
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="prescription-container">
            <div class="prescription-header">
                <div class="clinic-name">{{ clinicName }}</div>
                <div class="prescription-title">电子处方</div>
                <div>处方编号: {{ prescription.prescriptionId }}</div>
            </div>
            
            <div class="patient-info">
                <div class="info-item">
                    <div class="info-label">姓名</div>
                    <div class="info-value">{{ patient.name }}</div>
                </div>
                <div class="info-item">
                    <div class="info-label">性别</div>
                    <div class="info-value">{{ patient.gender }}</div>
                </div>
                <div class="info-item">
                    <div class="info-label">年龄</div>
                    <div class="info-value">{{ patient.age }}岁</div>
                </div>
                <div class="info-item">
                    <div class="info-label">就诊日期</div>
                    <div class="info-value">{{ prescription.visitDate }}</div>
                </div>
                <div class="info-item">
                    <div class="info-label">诊断</div>
                    <div class="info-value">{{ prescription.diagnosis }}</div>
                </div>
                <div class="info-item">
                    <div class="info-label">过敏史</div>
                    <div class="info-value">{{ patient.allergy || '无' }}</div>
                </div>
            </div>
            
            <div class="medication-section">
                <div class="section-title">药品明细</div>
                
                <div class="medication-item" v-for="(med, index) in prescription.medications" :key="index">
                    <div class="medication-name">{{ med.name }} {{ med.specification }}</div>
                    
                    <div class="medication-detail">
                        <div class="detail-label">用法:</div>
                        <div>{{ med.usage }}</div>
                    </div>
                    
                    <div class="medication-detail">
                        <div class="detail-label">用量:</div>
                        <div>{{ med.dosage }}</div>
                    </div>
                    
                    <div class="medication-detail">
                        <div class="detail-label">天数:</div>
                        <div>{{ med.days }}天</div>
                    </div>
                    
                    <div class="medication-detail">
                        <div class="detail-label">总量:</div>
                        <div>{{ med.totalQuantity }}</div>
                    </div>
                    
                    <div class="dosage-instruction" v-if="med.instructions">
                        <div class="instruction-title">用药指导</div>
                        <div class="instruction-item" v-for="(inst, idx) in med.instructions" :key="idx">
                            <div class="instruction-time">{{ inst.time }}:</div>
                            <div>{{ inst.description }}</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="caution-section">
                <div class="caution-title">注意事项</div>
                <ul class="caution-list">
                    <li v-for="(caution, index) in prescription.cautions" :key="index">{{ caution }}</li>
                </ul>
            </div>
            
            <div class="doctor-info">
                <div class="doctor-name">医师: {{ doctor.name }}</div>
                <div>执业证书: {{ doctor.license }}</div>
                <div class="date-info">开具日期: {{ prescription.issueDate }}</div>
            </div>
            
            <div class="action-buttons">
                <div class="action-button print-btn" @click="printPrescription">打印处方</div>
                <div class="action-button save-btn" @click="savePrescription">保存到手机</div>
            </div>
            
            <div class="footer">
                <p>本处方有效期为{{ prescription.validDays }}天，请按时取药</p>
                <p>如有疑问，请咨询医师或药师</p>
            </div>
        </div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                clinicName: '大贾村智慧药房',
                patient: {
                    name: '张大山',
                    gender: '男',
                    age: 52,
                    allergy: '青霉素'
                },
                prescription: {
                    prescriptionId: 'RX20230520001',
                    visitDate: '2025-05-20',
                    diagnosis: '上呼吸道感染，伴有咳嗽、咽痛',
                    issueDate: '2025-05-20',
                    validDays: 7,
                    medications: [
                        {
                            name: '阿莫西林胶囊',
                            specification: '0.25g*24粒',
                            usage: '口服',
                            dosage: '一次2粒，一日3次',
                            days: 5,
                            totalQuantity: '30粒',
                            instructions: [
                                {
                                    time: '早餐后',
                                    description: '温水送服，2粒'
                                },
                                {
                                    time: '午餐后',
                                    description: '温水送服，2粒'
                                },
                                {
                                    time: '晚餐后',
                                    description: '温水送服，2粒'
                                }
                            ]
                        },
                        {
                            name: '复方甘草片',
                            specification: '100片',
                            usage: '含服',
                            dosage: '一次2片，一日3次',
                            days: 5,
                            totalQuantity: '30片',
                            instructions: [
                                {
                                    time: '早餐后',
                                    description: '含服，2片'
                                },
                                {
                                    time: '午餐后',
                                    description: '含服，2片'
                                },
                                {
                                    time: '晚餐后',
                                    description: '含服，2片'
                                }
                            ]
                        },
                        {
                            name: '蓝芩口服液',
                            specification: '10ml*12支',
                            usage: '口服',
                            dosage: '一次1支，一日3次',
                            days: 5,
                            totalQuantity: '15支'
                        }
                    ],
                    cautions: [
                        '阿莫西林需饭后服用，减少胃肠道不适',
                        '服用阿莫西林期间禁止饮酒',
                        '复方甘草片不宜长期服用',
                        '服药期间多饮水，注意休息',
                        '如出现皮疹、呼吸困难等过敏反应，立即停药并就医'
                    ]
                },
                doctor: {
                    name: '李医生',
                    license: 'D20123456789'
                }
            },
            methods: {
                printPrescription() {
                    alert('处方打印功能已调用，在实际应用中会连接打印机');
                    // 实际实现中，这里会调用uni-app的打印API或调用系统打印对话框
                },
                savePrescription() {
                    alert('处方已保存到手机相册');
                    // 实际实现中，这里会将处方生成图片并保存到本地
                }
            }
        });
    </script>
</body>
</html>